#!/usr/bin/env python 
from socket import * 

HOST = 'localhost' 
PORT = 21567
BUFSIZ = 1024 
ADDR = (HOST, PORT) 

while True:
    udp_cli_sock = socket(AF_INET, SOCK_DGRAM) 
    udp_cli_sock.bind(('',4000))
    data = raw_input('> ') 
    if not data: 
        break 
    udp_cli_sock.sendto('%s\r\n' % data, ADDR) 
    data = udp_cli_sock.recvfrom(BUFSIZ)[0]
    if not data: 
        break 
    print data.strip() 

udp_cli_sock.close() 
